<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function get(min, max) {
            return Math.floor(Math.random() * (max - min + 1) + min);
        }
        let nun = get(1, 10);
        let i = 0;
        while (i < 10) {
            let n = parseInt(prompt('猜数字...'));
            if (n > nun) {
                alert('猜大了')
            } else if (n < nun) {
                alert('猜小了')
            } else {
                alert('猜对了')
                break;
            }
            i++;
        }
    </script>

</body>

</html>